using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;
using System.IO;

/// <summary>
/// Summary description for textFileParsers
/// </summary>

public class textFileParser
{
    public List<textLineParser> parsedLines = new List<textLineParser>();
    public textFileParser(Stream inputStream)
    {
        StreamReader fileReader = new StreamReader(inputStream);

        while (!fileReader.EndOfStream)
        {
            parsedLines.Add(new textLineParser(this, fileReader.ReadLine()));
        }

    }
}

public class textLineParser
{
    public List<string> values;
    public textFileParser parser;

    public textLineParser(textFileParser parser, string lineText)
    {
        this.parser = parser;
        this.values = new List<string>(lineText.Split('\t'));
    }

    public string getColumnValue(string columnName)
    {
        for (int i = 0; i < this.parser.parsedLines[0].values.Count; i++)
        {
            string colName = this.parser.parsedLines[0].values[i];
            if (colName.Equals(columnName)) return this.values[i];
        }
        throw new Exception("Invalid column name. Column can not be found");
    }

}

